The usual prefix for Calc is the key sequence C-x *. If you wish to use a different prefix, you can put
(global-set-key "NEWPREFIX" 'calc-dispatch)
in your .emacs file. (See Customizing Key Bindings, for more information on binding keys.) A convenient way to start Calc is with C-x * *; to make it equally convenient for users who use a different prefix, the prefix can be followed by =, &, #, \, /, + or - as well as * to start Calc, and so in many cases the last character of the prefix can simply be typed twice.
Calc is controlled by many variables, most of which can be reset from within Calc. Some variables are less involved with actual calculation and can be set outside of Calc using Emacs's customization facilities. These variables are listed below. Typing M-x customize-variable RET variable-name RET will bring up a buffer in which the variable's value can be redefined. Typing M-x customize-group RET calc RET will bring up a buffer which contains all of Calc's customizable variables. (These variables can also be reset by putting the appropriate lines in your .emacs file; See Init File.)
Some of the customizable variables are regular expressions. A regular expression is basically a pattern that Calc can search for. See Regular Expression Search to see how regular expressions work.
The variable
calc-settings-fileholds the file name in which commands like m m and Z P store “permanent” definitions. Ifcalc-settings-fileis not your user init file (typically ~/.emacs) and if the variablecalc-loaded-settings-fileisnil, then Calc will automatically load your settings file (if it exists) the first time Calc is invoked.The default value for this variable is
"~/.emacs.d/calc.el"unless the file ~/.calc.el exists, in which case the default value will be"~/.calc.el".
See Graphics.
The variablecalc-gnuplot-nameshould be the name of the GNUPLOT program (a string). If you have GNUPLOT installed on your system but Calc is unable to find it, you may need to set this variable. You may also need to set some Lisp variables to show Calc how to run GNUPLOT on your system, see Graphical Devices . The default value ofcalc-gnuplot-nameis"gnuplot".
See Graphical Devices.
The variablescalc-gnuplot-plot-commandandcalc-gnuplot-print-commandrepresent system commands to display and print the output of GNUPLOT, respectively. These may benilif no command is necessary, or strings which can include ‘%s’ to signify the name of the file to be displayed or printed. Or, these variables may contain Lisp expressions which are evaluated to display or print the output.The default value of
calc-gnuplot-plot-commandisnil, and the default value ofcalc-gnuplot-print-commandis"lp %s".
See Basic Embedded Mode.
The variablecalc-language-alistcontrols the languages that Calc will associate with major modes. When Calc embedded mode is enabled, it will try to use the current major mode to determine what language should be used. (This can be overridden using Calc's mode changing commands, See Mode Settings in Embedded Mode.) The variablecalc-language-alistconsists of a list of pairs of the form(MAJOR-MODE.LANGUAGE); for example,(latex-mode . latex)is one such pair. If Calc embedded is activated in a buffer whose major mode is MAJOR-MODE, it will set itself to use the language LANGUAGE.The default value of
calc-language-alistis((latex-mode . latex) (tex-mode . tex) (plain-tex-mode . tex) (context-mode . tex) (nroff-mode . eqn) (pascal-mode . pascal) (c-mode . c) (c++-mode . c) (fortran-mode . fortran) (f90-mode . fortran))
See Customizing Embedded Mode.
The variablecalc-embedded-announce-formulahelps determine what formulas C-x * a will activate in a buffer. It is a regular expression, and when activating embedded formulas with C-x * a, it will tell Calc that what follows is a formula to be activated. (Calc also uses other patterns to find formulas, such as ‘=>’ and ‘:=’.)The default pattern is
"%Embed\n\\(% .*\n\\)*", which checks for ‘%Embed’ followed by any number of lines beginning with ‘%’ and a space.The variable
calc-embedded-announce-formula-alistis used to setcalc-embedded-announce-formulato different regular expressions depending on the major mode of the editing buffer. It consists of a list of pairs of the form(MAJOR-MODE.REGEXP), and its default value is((c++-mode . "//Embed\n\\(// .*\n\\)*") (c-mode . "/\\*Embed\\*/\n\\(/\\* .*\\*/\n\\)*") (f90-mode . "!Embed\n\\(! .*\n\\)*") (fortran-mode . "C Embed\n\\(C .*\n\\)*") (html-helper-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*") (html-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*") (nroff-mode . "\\\\\"Embed\n\\(\\\\\" .*\n\\)*") (pascal-mode . "{Embed}\n\\({.*}\n\\)*") (sgml-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*") (xml-mode . "<!-- Embed -->\n\\(<!-- .* -->\n\\)*") (texinfo-mode . "@c Embed\n\\(@c .*\n\\)*"))Any major modes added to
calc-embedded-announce-formula-alistshould also be added tocalc-embedded-open-close-plain-alistandcalc-embedded-open-close-mode-alist.
See Customizing Embedded Mode.
The variablescalc-embedded-open-formulaandcalc-embedded-close-formulacontrol the region that Calc will activate as a formula when Embedded mode is entered with C-x * e. They are regular expressions; Calc normally scans backward and forward in the buffer for the nearest text matching these regular expressions to be the “formula delimiters”.The simplest delimiters are blank lines. Other delimiters that Embedded mode understands by default are:
- The TeX and LaTeX math delimiters ‘$ $’, ‘$$ $$’, ‘\[ \]’, and ‘\( \)’;
- Lines beginning with ‘\begin’ and ‘\end’ (except matrix delimiters);
- Lines beginning with ‘@’ (Texinfo delimiters).
- Lines beginning with ‘.EQ’ and ‘.EN’ (eqn delimiters);
- Lines containing a single ‘%’ or ‘.\"’ symbol and nothing else.
The variable
calc-embedded-open-close-formula-alistis used to setcalc-embedded-open-formulaandcalc-embedded-close-formulato different regular expressions depending on the major mode of the editing buffer. It consists of a list of lists of the form(MAJOR-MODE OPEN-FORMULA-REGEXP CLOSE-FORMULA-REGEXP), and its default value isnil.
See Customizing Embedded Mode.
The variablecalc-embedded-word-regexpdetermines the expression that Calc will activate when Embedded mode is entered with C-x * w. It is a regular expressions.The default value of
calc-embedded-word-regexpis"[-+]?[0-9]+\\(\\.[0-9]+\\)?\\([eE][-+]?[0-9]+\\)?".The variable
calc-embedded-word-regexp-alistis used to setcalc-embedded-word-regexpto a different regular expression depending on the major mode of the editing buffer. It consists of a list of lists of the form(MAJOR-MODE WORD-REGEXP), and its default value isnil.
See Customizing Embedded Mode.
The variablescalc-embedded-open-plainandcalc-embedded-open-plainare used to delimit “plain” formulas. Note that these are actual strings, not regular expressions, because Calc must be able to write these string into a buffer as well as to recognize them.The default string for
calc-embedded-open-plainis"%%% ", note the trailing space. The default string forcalc-embedded-close-plainis" %%%\n", without the trailing newline here, the first line of a Big mode formula that followed might be shifted over with respect to the other lines.The variable
calc-embedded-open-close-plain-alistis used to setcalc-embedded-open-plainandcalc-embedded-close-plainto different strings depending on the major mode of the editing buffer. It consists of a list of lists of the form(MAJOR-MODE OPEN-PLAIN-STRING CLOSE-PLAIN-STRING), and its default value is((c++-mode "// %% " " %%\n") (c-mode "/* %% " " %% */\n") (f90-mode "! %% " " %%\n") (fortran-mode "C %% " " %%\n") (html-helper-mode "<!-- %% " " %% -->\n") (html-mode "<!-- %% " " %% -->\n") (nroff-mode "\\\" %% " " %%\n") (pascal-mode "{%% " " %%}\n") (sgml-mode "<!-- %% " " %% -->\n") (xml-mode "<!-- %% " " %% -->\n") (texinfo-mode "@c %% " " %%\n"))Any major modes added to
calc-embedded-open-close-plain-alistshould also be added tocalc-embedded-announce-formula-alistandcalc-embedded-open-close-mode-alist.
See Customizing Embedded Mode.
The variablescalc-embedded-open-new-formulaandcalc-embedded-close-new-formulaare strings which are inserted before and after a new formula when you type C-x * f.The default value of
calc-embedded-open-new-formulais"\n\n". If this string begins with a newline character and the C-x * f is typed at the beginning of a line, C-x * f will skip this first newline to avoid introducing unnecessary blank lines in the file. The default value ofcalc-embedded-close-new-formulais also"\n\n". The final newline is omitted by C-x * f if typed at the end of a line. (It follows that if C-x * f is typed on a blank line, both a leading opening newline and a trailing closing newline are omitted.)The variable
calc-embedded-open-close-new-formula-alistis used to setcalc-embedded-open-new-formulaandcalc-embedded-close-new-formulato different strings depending on the major mode of the editing buffer. It consists of a list of lists of the form(MAJOR-MODE OPEN-NEW-FORMULA-STRING CLOSE-NEW-FORMULA-STRING), and its default value isnil.
See Customizing Embedded Mode.
The variablescalc-embedded-open-modeandcalc-embedded-close-modeare strings which Calc will place before and after any mode annotations that it inserts. Calc never scans for these strings; Calc always looks for the annotation itself, so it is not necessary to add them to user-written annotations.The default value of
calc-embedded-open-modeis"% "and the default value ofcalc-embedded-close-modeis"\n". If you change the value ofcalc-embedded-close-mode, it is a good idea still to end with a newline so that mode annotations will appear on lines by themselves.The variable
calc-embedded-open-close-mode-alistis used to setcalc-embedded-open-modeandcalc-embedded-close-modeto different strings expressions depending on the major mode of the editing buffer. It consists of a list of lists of the form(MAJOR-MODE OPEN-MODE-STRING CLOSE-MODE-STRING), and its default value is((c++-mode "// " "\n") (c-mode "/* " " */\n") (f90-mode "! " "\n") (fortran-mode "C " "\n") (html-helper-mode "<!-- " " -->\n") (html-mode "<!-- " " -->\n") (nroff-mode "\\\" " "\n") (pascal-mode "{ " " }\n") (sgml-mode "<!-- " " -->\n") (xml-mode "<!-- " " -->\n") (texinfo-mode "@c " "\n"))Any major modes added to
calc-embedded-open-close-mode-alistshould also be added tocalc-embedded-announce-formula-alistandcalc-embedded-open-close-plain-alist.
See Displaying Selections.
The variablecalc-highlight-selections-with-facesdetermines how selected sub-formulas are distinguished. Ifcalc-highlight-selections-with-facesis nil, then a selected sub-formula is distinguished either by changing every character not part of the sub-formula with a dot or by changing every character in the sub-formula with a ‘#’ sign. Ifcalc-highlight-selections-with-facesis t, then a selected sub-formula is distinguished either by displaying the non-selected portion of the formula withcalc-nonselected-faceor by displaying the selected sub-formula withcalc-nonselected-face.
The variable
calc-multiplication-has-precedencedetermines whether multiplication has precedence over division in algebraic formulas in normal language modes. Ifcalc-multiplication-has-precedenceis non-nil, then multiplication has precedence (and, for certain obscure reasons, is right associative), and so for example ‘a/b*c’ will be interpreted as ‘a/(b*c)’. Ifcalc-multiplication-has-precedenceisnil, then multiplication has the same precedence as division (and, like division, is left associative), and so for example ‘a/b*c’ will be interpreted as ‘(a/b)*c’. The default value ofcalc-multiplication-has-precedenceist.
The variable
calc-undo-lengthdetermines the number of undo steps that Calc will keep track of whencalc-quitis called. Ifcalc-undo-lengthis a non-negative integer, then this is the number of undo steps that will be preserved; ifcalc-undo-lengthhas any other value, then all undo steps will be preserved. The default value ofcalc-undo-lengthis ‘100’.